<?php
namespace ShopApi\Controller;
use Zend\Mvc\Controller\AbstractRestfulController;
use Zend\View\Model\JsonModel;
class ShopComplaintsRepliesReviewsRatingsApiController extends AbstractRestfulController
{
    public function getList()
    {			
			
    }
    public function get($shopdata)
    {		
		header('Access-Control-Allow-Origin: *');	
		$complaintsTable=$this->getServiceLocator()->get('Models\Model\ComplaintsFactory');
		$complaintRelpiesTable=$this->getServiceLocator()->get('Models\Model\ComplaintRelpiesFactory');
		$reviwesTable=$this->getServiceLocator()->get('Models\Model\ReviewsFactory');
		$ratingTable=$this->getServiceLocator()->get('Models\Model\RatingFactory');
		$orderDeliveryDetailsTable=$this->getServiceLocator()->get('Models\Model\OrderDeliveryDetailsFactory');
		$explodeId=explode('-',$shopdata);
			$shop_id=$explodeId[1];
		$getcountComplaints = $complaintsTable->totalComplaints($shop_id);
		$getcountComplaintRelpies = $complaintRelpiesTable->totalComplaintRelpies($shop_id);
		$getcountofreviews = $reviwesTable->getReviewsAndRatingsconfirmShop($shop_id);
		$getRatingsofShops1='';$getRatingsofShops2='';$getRatingsofShops3='';$getRatingsofShops4='';$getRatingsofShops5='';
		for($i=1;$i<=5;$i++){
			if($i==1){
				$getRatingsofShops1 = $ratingTable->getRatingsofShops($shop_id,$i);
			}else if($i==2){
				$getRatingsofShops2 = $ratingTable->getRatingsofShops($shop_id,$i);
			}else if($i==3){
				$getRatingsofShops3 = $ratingTable->getRatingsofShops($shop_id,$i);
			}else if($i==4){
				$getRatingsofShops4 = $ratingTable->getRatingsofShops($shop_id,$i);
			}else if($i==5){
				$getRatingsofShops5 = $ratingTable->getRatingsofShops($shop_id,$i);
			}
		}		
		if( $getcountComplaints!=0 || $getcountComplaintRelpies!=0 || $getcountofreviews!=0 || 
		$getRatingsofShops1!=0 || $getRatingsofShops2!=0 ||	$getRatingsofShops3!=0 
		|| $getRatingsofShops4!=0 || $getRatingsofShops5!=0 ){
			return new JsonModel(array(
				'cntComplanits' 		=> $getcountComplaints,
				'cntReplies' 		    => $getcountComplaintRelpies,
				'cntReviews' 		    => $getcountofreviews,
				'cntRating1' 		    => $getRatingsofShops1,
				'cntRating2' 		    => $getRatingsofShops2,
				'cntRating3' 		    => $getRatingsofShops3,
				'cntRating4' 		    => $getRatingsofShops4,				
				'cntRating5' 		    => $getRatingsofShops5,								
			));
		}else{
			return new JsonModel(array(
				'cntComplanits' 		=> 0,
				'cntReplies' 		    => 0,
				'cntReviews' 		    => 0,
				'cntRating1' 		    => 0,
				'cntRating2' 		    => 0,
				'cntRating3' 		    => 0,
				'cntRating4' 		    => 0,				
				'cntRating5' 		    => 0,		
			));
		}	
    }
    public function create($data)
    {
		
    }
    public function update($complaint_id,$data)
    {
		
    }
    public function delete($id)
    {
       
    }
}